<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>获取元素尺寸</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            padding: 10px;
            border: 5px solid red;
            background: yellow;
        }
    </style>
</head>
<body>
    <div id="box"></div>
    <script>
        //内容宽度
        console.log(getComputedStyle(box).width)
        // content+padding+border
        console.log(box.offsetWidth, box.offsetHeight)
        // content+padding
        console.log(box.clientWidth, box.clientHeight)
    </script>
</body>
</html>